
package com.insigma.business.qrcode.common.converter;

import com.insigma.business.qrcode.job.dto.*;
import com.insigma.business.qrcode.job.dto.request.JobCandidateResumeInsertRequest;
import com.insigma.business.qrcode.job.dto.request.JobCandidateResumeSearchRequest;
import com.insigma.business.qrcode.job.dto.request.JobCandidateResumeUpdateRequest;
import com.insigma.business.qrcode.job.dto.search.JobCandidateResumeBSearcher;
import com.insigma.business.qrcode.job.entity.JobCandidateResumeDO;
import org.springframework.beans.BeanUtils;

import java.util.ArrayList;
import java.util.List;


public class JobCandidateResumeProviderConverter extends AbstractConverter<JobCandidateResumeDTO, JobCandidateResumeDO> {

    private final static JobCandidateResumeProviderConverter jobCandidateResumeConverter = new JobCandidateResumeProviderConverter();

    private JobCandidateResumeProviderConverter(){}

    
    public static JobCandidateResumeBSearcher convertRequestSO2Searcher(final JobCandidateResumeSearchRequest request){
        final JobCandidateResumeBSearcher jobCandidateResumeBSearcher = new JobCandidateResumeBSearcher(request.getPageNo(),
        request.getPageSize(),request.getSortKeyValueJoint());
        BeanUtils.copyProperties(request,jobCandidateResumeBSearcher);
        return jobCandidateResumeBSearcher;
    }

    
    public static JobCandidateResumeDO convertRequestUO2DO(final JobCandidateResumeUpdateRequest jobCandidateResumeUpdateRequest) {
        final JobCandidateResumeDO jobCandidateResumeDO = new JobCandidateResumeDO();
        BeanUtils.copyProperties(jobCandidateResumeUpdateRequest,jobCandidateResumeDO);
        
        return jobCandidateResumeDO;
    }

    
    public static JobCandidateResumeDO convertRequestIO2DO(final JobCandidateResumeInsertRequest jobCandidateResumeInsertRequest) {
        final JobCandidateResumeDO jobCandidateResumeDO = new JobCandidateResumeDO();
        BeanUtils.copyProperties(jobCandidateResumeInsertRequest,jobCandidateResumeDO);
        return jobCandidateResumeDO;
    }

    
    public static List<JobCandidateResumeDTO> convertResponseDOList2DTOList(final List<JobCandidateResumeDO> jobCandidateResumeDOList){
        return jobCandidateResumeConverter.convertGenericResponseDOList2DTOList(jobCandidateResumeDOList);
    }

    
    public static JobCandidateResumeDTO convertResponseDO2DTO(final JobCandidateResumeDO jobCandidateResumeDO){
        return jobCandidateResumeConverter.convertGenericResponseDO2DTO(jobCandidateResumeDO);
    }

    public static List<JobCandidateResumeDTO> convertResponseBOList2DTOList(List<JobResumeDetailBO> jobCandidateResumeDOList) {
        List<JobCandidateResumeDTO> viewObjList = new ArrayList<>();
        for (JobResumeDetailBO jobResumeDetailBO : jobCandidateResumeDOList) {
            JobCandidateResumeDTO dto = new JobCandidateResumeDTO();
            BeanUtils.copyProperties(jobResumeDetailBO, dto);
            viewObjList.add(dto);
        }
        return viewObjList;
    }

    @Override
    protected JobCandidateResumeDTO doConvertResponseDO2DTO(JobCandidateResumeDO jobCandidateResumeDO) {
        final JobCandidateResumeDTO jobCandidateResumeDTO = new JobCandidateResumeDTO();
        try {
            BeanUtils.copyProperties(jobCandidateResumeDO, jobCandidateResumeDTO);
        }catch(RuntimeException be){
            
            return null;
        }
        return jobCandidateResumeDTO;
    }

}
